
capture log close

set more off
set matsize 10000

use rep_final, clear

	*noncitizens
	keep if cit==0
	*married last year, currently still married with spouse present
	keep if marrinyr==2 & married==1 
	*spouse info is avail.
	drop if citizen_sp==.

* Define control variables 

	local demog "age age2 male yreduc i.racegr"	
	local imm "ysm i.bpl " 
	local fe "i.statefip i.yrmarr "
	
	local full "`demog' `imm' `fe' "


	
	*full control, with bpl
	
	local a=1
	foreach controlgr of varlist controlgrdacacutoff controlgrdaca_agematch   ///
								 controlgrchildimm controlgrdacahs {
							
		foreach depvar of varlist cit_sp  {
		
				
			display ""
			display "--------------------------------------"
			display "Control group: `controlgr'"
			display "Dependent Variable: `depvar' "
			
			
			display "--------------------------------------"
		
			*use ib.var to set the base year
		
			reg `depvar' ib2011.yrmarr##i.treatgr `full' if daca==1|`controlgr'==1 [pweight=perwt], cluster(statefip)	
			est sto e`a'
			
			local coefinter 2008.yrmarr#1.treatgr  2009.yrmarr#1.treatgr ///
							2010.yrmarr#1.treatgr  2011.yrmarr#1.treatgr ///
							2012.yrmarr#1.treatgr      					  ///
							2013.yrmarr#1.treatgr  2014.yrmarr#1.treatgr ///
							2015.yrmarr#1.treatgr  2016.yrmarr#1.treatgr ///
							2017.yrmarr#1.treatgr  2018.yrmarr#1.treatgr ///
							2019.yrmarr#1.treatgr  

			coefplot, keep(`coefinter') ///
				coeflabels( 2008.yrmarr#1.treatgr = "2008"  ///
							2009.yrmarr#1.treatgr = "2009"  ///
							2010.yrmarr#1.treatgr = "2010"  ///
							2011.yrmarr#1.treatgr = "2011"   ///
							2012.yrmarr#1.treatgr = "2012"  ///
							2013.yrmarr#1.treatgr = "2013" ///
							2014.yrmarr#1.treatgr = "2014" ///
							2015.yrmarr#1.treatgr = "2015" ///
							2016.yrmarr#1.treatgr = "2016" ///
							2017.yrmarr#1.treatgr = "2017" ///
							2018.yrmarr#1.treatgr = "2018" ///
							2019.yrmarr#1.treatgr=  "2019") ///		 
					vertical 							 ///
					yline(0)							 ///
					xline(5, lpattern(dash))			///
					ytitle("Coefficient")				///
					xtitle("Year") ///
					addplot(line @b @at)				///
					ciopts(recast(rcap))				///
					/*rescale(100)*/						///
					omitted baselevels			 /*keep the baseline in the graph*/	
			
		graph export "FigureA1-`a'.png", replace
		

		local a=`a'+1
		}
		
		*dep var mean
	
		sum cit_sp [fweight=perwt] if e(sample) 	
		
	}
		

	

	
